#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	long long n, x, b = 0, c = 0, count = 0;
	scanf("%ld %ld", &n, &x);
	int a[1000000];
	if (n >= 1 && n <= 10 ^ 6 && x >= 0 && x <= 9)
	{
		for (int i = 1; i <= n; i++)
		{
			b = i;
			while (b != 0)
			{
				c = b % 10;
				b = b / 10;
				if(c==x)
					count++;
			}

		}
		cout << count << endl;
	}
	return 0;
}